package com.queen.restaurant.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;

@Entity
@javax.persistence.Table(name="t_table")
public class Table implements Serializable{
	
	public static final int TABLE_STATUS_FREE = 0x000301;
	public static final int TABLE_STATUS_USING = 0x000302;
	public static final int TABLE_STATUS_BOOKING = 0x000303;
	public static final int TABLE_STATUS_LOCK = 0x000304;
	
	//主键uuid
	@Id
	@Column(name="id",nullable=false,length=32)
	@GenericGenerator(name="hibernate-uuid",strategy="uuid")
	@GeneratedValue(generator="hibernate-uuid")
	private String id;
	
	@ManyToOne(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "restaurantId", nullable=false, referencedColumnName="id")
	private Restaurant restaurant;
	@Column
	private String tableName;
	@Column
	private int seatNum;
	@Column
	private int tableStatus;
	@Column
	private boolean isRoom;
	
//	private List<Order> orders = new ArrayList<Order>();

	public Table() {
	}

	public Table(Restaurant restaurant, String tableName, int seatNum,
			int tableStatus, boolean isRoom) {
		this.restaurant = restaurant;
		this.tableName = tableName;
		this.seatNum = seatNum;
		this.tableStatus = tableStatus;
		this.isRoom = isRoom;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@JsonIgnore
	public Restaurant getRestaurant() {
		return restaurant;
	}

	public void setRestaurant(Restaurant restaurant) {
		this.restaurant = restaurant;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public int getSeatNum() {
		return seatNum;
	}

	public void setSeatNum(int seatNum) {
		this.seatNum = seatNum;
	}

	public int getTableStatus() {
		return tableStatus;
	}

	public void setTableStatus(int tableStatus) {
		this.tableStatus = tableStatus;
	}

	public boolean getIsRoom() {
		return isRoom;
	}

	public void setIsRoom(boolean isRoom) {
		this.isRoom = isRoom;
	}
//	public List<Order> getOrders() {
//		return orders;
//	}
//
//	public void setOrders(List<Order> orders) {
//		this.orders = orders;
//	}
}
